package PTA;
//6-1 Shape类 Java习题10_
import java.util.Scanner;

/*

public class xt10_6_1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double length = scan.nextDouble();
        Square s = new Square(length);
        System.out.printf("%.2f ",s.getPerimeter());
        System.out.printf("%.2f\n",s.getArea());

        length = scan.nextDouble();
        double wide = scan.nextDouble();
        Rectangle r = new Rectangle(length,wide);
        System.out.printf("%.2f ",r.getPerimeter());
        System.out.printf("%.2f\n",r.getArea());

        double radius = scan.nextDouble();
        Circle c = new Circle(radius);
        System.out.printf("%.2f ",c.getPerimeter());
        System.out.printf("%.2f\n",c.getArea());

        scan.close();
    }
}


abstract class shape {//抽象类
    */
/*抽象方法 求面积*//*

    public abstract double getArea();
    */
/* 抽象方法 求周长 *//*

    public abstract double getPerimeter( );
}

class Square extends shape {
    private double r;//边长
    //构造方法
    public Square(double r){
        this.r = r;
    }
    public double getArea(){ //求面积
        return r * r;
    }
    public double getPerimeter(){//求周长
        return 4 * r;
    }
}

class Rectangle extends shape {
    private double r,h;//边长
    //构造方法
    public Rectangle(double r, double h){
        this.r = r;
        this.h = h;
    }
    public double getArea(){ //求面积
        return h * r;
    }
    public double getPerimeter(){//求周长
        return 2 * (r + h);
    }
}

class Circle extends shape {
    private double r;//边长
    //构造方法
    public Circle(double r){
        this.r = r;
    }
    public double getArea(){ //求面积
        return Math.PI * r * r;
    }
    public double getPerimeter(){//求周长
        return 2 * r * Math.PI;
    }
}*/
